﻿#ifndef PARSEHEX_H
#define PARSEHEX_H

#include <QString>
#include <QFile>
#include <QDebug>

typedef struct{
    unsigned char datalen;
    unsigned short addr;
    unsigned char datatype;
    unsigned char databuf[16];
    unsigned char checkout;
}HexFormatForLine;

class ParseHex
{
public:
    ParseHex();
    void clear();
    bool parse(QString fileName);
    QString error_info;
    QByteArray bin_data;
    QByteArray flash_data;
    QByteArray flash_end_data;
private:
    char ReadHexLineData(const QByteArray & ba, QByteArray &  out, QByteArray &  out2);//return 0: ok  1:hex文件结束 2：hex文件有误
    char HexToBin2(HexFormatForLine* ba,QByteArray & out3);
    QString fileName;
    unsigned int ExStageAddr = 0x00;//扩展段地址
    unsigned int ExLineAddr = 0x00;//扩展线性地址
    unsigned int absoluteAddrLocal = 0x00;//本地记录绝对地址
};

#endif // PARSEHEX_H
